package Exists;

public class Student extends RuntimeException {
    public Student() {

    }

    public Student(String message) {
        super(message);
    }

    String name;
    String sex;
    int age ;



    public String getName() {
        return name;
    }

    public String getSex() {
        return sex;
    }

    public int getAge() {
        return age;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setSex(String sex) {

        if(sex.equals("男")||sex.equals("女")){
            this.sex = sex;

        }else{
            System.out.println("性别不正确");
        }

    }

    public void setAge(int age) {
        try {
            if(age >= 15 && age <= 50){

                this.age = age;
            }else{

            }


        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", sex='" + sex + '\'' +
                ", age=" + age +
                '}';
    }


}
